-
Notifications
You must be signed in to change notification settings - Fork 461
Refactor system bar visibility handling on Android #2905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ne0rrmatrix
wants to merge
5
commits into
CommunityToolkit:main
Choose a base branch
from
ne0rrmatrix:UpdateAndroidFullScreen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor system bar visibility handling on Android #2905
ne0rrmatrix
wants to merge
5
commits into
CommunityToolkit:main
from
ne0rrmatrix:UpdateAndroidFullScreen
+19
−63
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Modernized the handling of system bar visibility in the `MauiMediaElement` class by replacing the legacy `SetSystemBarsVisibility` method with a new `SetStatusBarsHidden` method. This leverages modern Android APIs (`WindowManagerFlags` and `WindowInsetsControllerCompat`) for better compatibility and maintainability. Introduced static properties (`window`, `decorView`, `insetsController`) to encapsulate window-related logic with improved error handling. Removed legacy code for Android versions below API 30, simplifying the codebase. Updated fullscreen handling logic to align with modern Android development practices. Improved layout invalidation on fullscreen button clicks and ensured consistent system bar visibility management across the codebase. Enhanced code readability, maintainability, and robustness by reducing duplication, leveraging modern APIs, and improving error handling. Has legacy support from android 26 and is tested against 26, 33,34, and 35 with both button and gesture navigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the system bar visibility handling in the MauiMediaElement
Android class by replacing legacy APIs with modern Android approaches. The change improves maintainability and compatibility while fixing issues with tab bar sizing after exiting fullscreen mode.
Key Changes:
- Replaced legacy
SetSystemBarsVisibility
method withSetStatusBarsHidden
using modern Android APIs - Introduced static properties for better window-related logic encapsulation
- Removed support for Android versions below API 26, simplifying the codebase
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Outdated
Show resolved
Hide resolved
…android.cs Good catch Co-authored-by: Copilot <[email protected]>
Refactored `MauiMediaElement` to improve encapsulation by removing static properties (`window`, `decorView`, `insetsController`) and localizing their instantiation within the `SetStatusBarsHidden` method. This change reduces reliance on static properties and enhances maintainability. Updated `using` directives to include aliases for `Android.Views.View` and `Android.Views.Window` to resolve naming conflicts.
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Modernized the handling of system bar visibility in the
MauiMediaElement
class by replacing the legacySetSystemBarsVisibility
method with a newSetStatusBarsHidden
method. This leverages modern Android APIs (WindowManagerFlags
andWindowInsetsControllerCompat
) for better compatibility and maintainability.Introduced static properties (
window
,decorView
,insetsController
) to encapsulate window-related logic with improved error handling. Removed legacy code for Android versions below API 30, simplifying the codebase.Updated fullscreen handling logic to align with modern Android development practices. Improved layout invalidation on fullscreen button clicks and ensured consistent system bar visibility management across the codebase.
Enhanced code readability, maintainability, and robustness by reducing duplication, leveraging modern APIs, and improving error handling.
Has legacy support from android 26 and is tested against 26, 33,34, and 35 with both button and gesture navigation.
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
Tested against android 26, 33, 34, and 35. I tested against gesture navigation and 3 button navigation on each platform with media element sample app page. It fixes the issue raised where tab bar size is incorrect upon leaving full screen mode.